package com.ctjsoft.threadstatus;

/**
 * 测试线程的join方法
 * join方法-线程插队执行
 * @author liaoyy
 * @date Created in 2022/1/10 21:38
 */
public class ThreadJoinDemo implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("插队线程" + i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadJoinDemo threadJoinDemo = new ThreadJoinDemo();
        Thread thread = new Thread(threadJoinDemo);
        thread.start();

        for (int i = 0; i < 100; i++) {
            System.out.println("主线程" + i);
            if (i == 10){
                thread.join();
            }
        }
    }
}
